﻿@page "/identity/users"
@namespace  ERP.Abp.IdentityManagement.Blazor.AntDesignUI.Pages
@using ERP.Abp.IdentityManagement.Blazor.AntDesignUI.Pages
@using ERP.Abp.Identity
@using ERP.Abp.AntDesignUI
@using ERP.Abp.PermissionManagement.Blazor.AntDesignUI.Components
@using Volo.Abp.UI.Navigation
@inherits AbpCrudPageBase<IIdentityUserAppService, IdentityUserDto, Guid, GetIdentityUsersInput, IdentityUserCreateDto, IdentityUserUpdateDto>
@implements  ERP.Abp.AntDesignUI.IReuseTabsPage
@inject ModalService ModalService
@inject IMyMenuManager IMyMenuManager
@inject MessageService _message
@inject ConfirmService _confirmService
 <GridContent>
    <AntDesign.Card  >
         <AdminTable   TItem="IdentityUserDto"  Columns="UserManagementTableColumns"  OnChange="OnDataGridReadAsync"  RemoteDataSource="true"  DataSource="@Entities"  Total="@TotalCount"  PageSize="@PageSize"  PageIndex= "@CurrentPage"   Loading="@Loading" >
            <SearchTemplate>
                  <AntDesign.Form  Model="GetListInput" TModel="GetIdentityUsersInput" Name="advanced_search" Class="ant-advanced-search-form">
                    <AntDesign.Row Gutter="24">
                            <AntDesign.GridCol Span="8"  >
                                <FormItem Label="@($"用户名")" >
                                  <AntDesign.Input @bind-Value="@(context.Filter)" OnPressEnter="SearchEntitiesAsync" OnBlur="SearchEntitiesAsync" Placeholder="placeholder" /> 
                                </FormItem>
                            </AntDesign.GridCol>
                    </AntDesign.Row>
                </AntDesign.Form>
            </SearchTemplate>
            <ToolbarRightButtonTemplate>
                    <AntDesign.ButtonGroup>
                         <AntDesign.Button Icon="@IconType.Outline.Plus" Type="primary" OnClick="OpenCreateModalAsync" >@L["NewUser"]</AntDesign.Button>
                        <AntDesign.Button Icon="@IconType.Outline.Search" Type="primary" OnClick=" SearchEntitiesAsync" >查询</AntDesign.Button>
                     </AntDesign.ButtonGroup>
            </ToolbarRightButtonTemplate>
        </AdminTable>
    </AntDesign.Card>
</GridContent>
@if (HasCreatePermission)
{
    <Modal @ref="CreateModal" Title="@L["NewUser"]" Visible="@CreateModalVisible" OnCancel="@CloseCreateModalAsync" OnOk="CreateEntityAsync">
        <Form
            @ref="@CreateFormRef"
            Layout="@FormLayout.Vertical"
            Model="@NewEntity">
            @if (CreateModalVisible)
            {
                <Tabs>
                    <TabPane Tab="@L["UserInformations"]">
                        <FormItem Label="@L["DisplayName:UserName"]">
                            <Input @bind-Value="@context.UserName"/>
                        </FormItem>
                        <FormItem Label="@L["DisplayName:Name"]">
                            <Input @bind-Value="@context.Name"/>
                        </FormItem>
                        <FormItem Label="@L["DisplayName:Surname"]">
                            <Input @bind-Value="@context.Surname"/>
                        </FormItem>
                        <FormItem Label="@L["DisplayName:Password"]">
                            <InputPassword  @bind-Value="@context.Password"/>
                        </FormItem>
                        <FormItem Label="@L["DisplayName:Email"]">
                            <Input @bind-Value="@context.Email"/>
                        </FormItem>
                        <FormItem Label="@L["DisplayName:PhoneNumber"]">
                            <Input @bind-Value="@context.PhoneNumber"/>
                        </FormItem>
                        <FormItem>
                            <Checkbox @bind-Value="context.IsActive">@L["DisplayName:IsActive"]</Checkbox>
                        </FormItem>
                        <FormItem>
                            <Checkbox @bind-Value="context.LockoutEnabled">@L["DisplayName:LockoutEnabled"]</Checkbox>
                        </FormItem>
                    </TabPane>
                    
                    <TabPane Tab="@L["Roles"]">
                          @foreach (var role in NewUserRoles)
                          {
                              <FormItem WrapperColOffset="2">
                                  <Checkbox @bind-Value="role.IsAssigned">@role.Name</Checkbox>
                              </FormItem>
                          }
                    </TabPane>
                </Tabs>
            }
        </Form>
    </Modal>
}
@if (HasUpdatePermission)
{
    <Modal @ref="EditModal" Title="@L["Edit"]" Visible="@EditModalVisible" OnCancel="@CloseEditModalAsync" OnOk="UpdateEntityAsync" MaxBodyHeight="300px"> 
        <Form
            @ref="@EditFormRef"
            Layout="@FormLayout.Vertical"
            Model="@EditingEntity">
            @if (EditModalVisible)
            {
                <Tabs>
                    <TabPane Tab="@L["UserInformations"]">
                        <FormItem Label="@L["DisplayName:UserName"]">
                            <Input @bind-Value="@context.UserName"/>
                        </FormItem>
                        <FormItem Label="@L["DisplayName:Name"]">
                            <Input @bind-Value="@context.Name"/>
                        </FormItem>
                        <FormItem Label="@L["DisplayName:Surname"]">
                            <Input @bind-Value="@context.Surname"/>
                        </FormItem>
                        <FormItem Label="@L["DisplayName:Password"]">
                            <InputPassword  @bind-Value="@context.Password"/>
                        </FormItem>
                        <FormItem Label="@L["DisplayName:Email"]">
                            <Input @bind-Value="@context.Email"/>
                        </FormItem>
                        <FormItem Label="@L["DisplayName:PhoneNumber"]">
                            <Input @bind-Value="@context.PhoneNumber"/>
                        </FormItem>
                        <FormItem>
                            <Checkbox @bind-Value="context.IsActive">@L["DisplayName:IsActive"]</Checkbox>
                        </FormItem>
                        <FormItem>
                            <Checkbox @bind-Value="context.LockoutEnabled">@L["DisplayName:LockoutEnabled"]</Checkbox>
                        </FormItem>
                    </TabPane>
                    
                    <TabPane Tab="@L["Roles"]">
                          @foreach (var role in EditUserRoles)
                          {
                              <FormItem WrapperColOffset="2">
                                  <Checkbox @bind-Value="role.IsAssigned">@role.Name</Checkbox>
                              </FormItem>
                          }
                    </TabPane>
                </Tabs>
            }
        </Form>
    </Modal>
}
@if (HasManagePermissionsPermission)
{
    <PermissionManagementModal @ref="PermissionManagementModal"/>
}


 